package kr.ac.skhu.m.util;

public class PaggingUtil {
	
	protected int curPage;
	protected int totalPage;
	protected int prev;
	protected int first;
	protected int next;
	protected int last;
	protected int beginPage;
	protected int endPage;
	
	public PaggingUtil(int curPage, int totalPage) {
		this.first = 1;
		this.curPage = curPage;
		this.totalPage = totalPage;
		this.last = totalPage;
	}
	
	public int getCurPage() {
		return curPage;
	}
	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public int getPrev() {
		
		this.prev = curPage - 1;
		
		if(curPage == 1){
			this.prev =  1;
		}
		
		return prev;
	}
	public void setPrev(int prev) {
		this.prev = prev;
	}
	public int getFirst() {
		return first;
	}
	public void setFirst(int first) {
		this.first = first;
	}
	public int getNext() {
		
		this.next = curPage + 1;
		
		if(curPage == totalPage){
			this.next = curPage;
		}
		
		return this.next;
	}
	public void setNext(int next) {
		this.next = next;
	}
	public int getLast() {
		return last; 
	}
	public void setLast(int last) {
		this.last = last;
	}
	public int getBeginPage() {
		
		beginPage = ((( curPage-1 ) / 5 + 1) * 5 ) - 4;
		
		return beginPage;
	}
	public void setBeginPage(int beginPage) {
		this.beginPage = beginPage;
	}
	public int getEndPage() {
		endPage = (( curPage-1 ) / 5 + 1) * 5;
		
		if(endPage >= totalPage){
			endPage = totalPage;
		}
		
		return endPage;
	}
	public void setEndPage(int endPage) {
		this.endPage = endPage;
	}
	
}
